﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Vivasky.Labs.Utils;
using TortoiseSVNCleaner.Properties;
using System.IO;

namespace TortoiseSVNCleaner
{
	public partial class Default : Form
	{
		public Default()
		{
			InitializeComponent();
		}

		private void btnSelectFolder_Click(object sender, EventArgs e)
		{
			this.folderBrowserDialog1.ShowDialog();
			this.txtFolder.Text = this.folderBrowserDialog1.SelectedPath;
		}

		private void btnDoClean_Click(object sender, EventArgs e)
		{
			if (this.txtFolder.Text == string.Empty) {
				MessageBox.Show("请选择待清理的文件夹");
				return;
			}

			List<DirectoryInfo> failedFolders = new List<DirectoryInfo>();
			var okFolders = FileUtils.DeleteFolder(Properties.Settings.Default.TortoiseSVNFolders.Split(',').ToList(), this.txtFolder.Text, out failedFolders);

			//bind result
			if (this.cbxShowType.Checked) {
				this.dataGridView1.DataSource = okFolders;
			} else {
				this.dataGridView1.DataSource = failedFolders;
			}
		}
	}
}
